<?php
class AutoRateConfig_6h
{

    public $betnameArr;
    public $autorateArr;
    public $table_name = "autorate_config_6h";
    public $db;
    public $tbl;

    public function AutoRateConfig_6h( $betnameArr, $autorateArr, $gametype = 0 )
    {
        global $g_gametype_3d;
        $this->betnameArr = $betnameArr;
        $this->autorateArr = $autorateArr;
        $this->db = new DB();
        $this->table_name = "autorate_config_".$g_gametype_3d[$gametype]['en'];
    }

    public function checkIfAutoRate( $bettype_id )
    {
        return in_array( $bettype_id, $this->autorateArr );
    }

    public function getAutoRateAll( )
    {
        $sql = "!!SELECT * FROM ".$this->table_name." WHERE 1";
        $result = $this->db->query( $sql );
        $reArr = array();
        while ( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) )
        {
            $tempIdx = $row['bettype_id'];
            $reArr[$tempIdx] = $row;
        }
        if ( 0 < count( $reArr ) )
        {
            return $reArr;
        }
        return false;
    }

    public function updateAutoRate( $dataArr )
    {
        foreach ( $dataArr as $val )
        {
            $sql = " UPDATE ".$this->table_name." SET ";
            $sql .= " money =".$val['money'];
            $sql .= ",downrate =".$val['downrate'];
            $sql .= ",uprate =".$val['uprate'];
            $sql .= ",limitrate =".$val['limitrate'];
            $sql .= ",money1 =".$val['money1'];
            $sql .= ",downrate1 =".$val['downrate1'];
            $sql .= ",uprate1 =".$val['uprate1'];
            $sql .= ",amount_255 =".$val['amount_255'];
            $sql .= ",typeflag =".$val['typeflag'];
            $sql .= " WHERE bettype_id=".$val['id']." AND subid=".$val['subid'];
            $this->db->query( $sql );
        }
    }

}

?>